package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.SysDeptDao1;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.basis.entity.po.SysDept;
import hw.topevery.framework.db.CommandType;
import hw.topevery.framework.entity.DbCsp;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * 部门表
 *
 * @author code-generate
 * @date 2022-01-06
 */
@Repository
public class SysDeptDaoImpl1 extends BaseDaoImpl<SysDept> implements SysDeptDao1 {
    @Override
    public <P extends DbCsp> List<SysDept> getSearch(P para) {
        return null;
    }



    @Override
    public List<SysDept> getGardenBasicDept() {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT\n" +
                "            a.*\n" +
                "        FROM\n" +
                "            t_sys_dept a\n" +
                "        WHERE\n" +
                "            c_dept_pid = 'ACDB2E71-F9B3-4450-B7AD-FC9A1F735CDE'"+
                "            AND a.c_db_status = 0");

        AtomicReference<List<SysDept>> vo = new AtomicReference<>(new ArrayList<>());
        run(sb.toString(), CommandType.Text, dbCommand -> {
            vo.set(dbCommand.executeToList(SysDept.class));
        });

        return vo.get();
    }

    @Override
    public List<SysDept> list() {
        StringBuffer sb = new StringBuffer();
        sb.append("select * from t_sys_dept where c_db_status= 0 and c_dept_status = 10101");

        AtomicReference<List<SysDept>> vo = new AtomicReference<>(new ArrayList<>());
        run(sb.toString(), CommandType.Text, dbCommand -> {
            vo.set(dbCommand.executeToList(SysDept.class));
        });

        return vo.get();
    }
}
